import 'dart:convert';
import 'dart:math';
import 'package:http/http.dart' as Http;
import 'package:flutter/services.dart';
import 'package:flutter_elf/utils/permission_utils.dart';
/// CreateTime 2020/7/6 15:10
/// CreateUser chen 
/// ProjectName flutter_elf
import 'package:flutter_elf/config/component_index.dart';

class SalaryPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return SalaryPageState();
  }
}
class SalaryPageState extends State<SalaryPage>{

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
//    get();
  }

  get()async {
    String url = 'aHR0cCUzQS8vY2hlbjQxMjExNS5vc3MtY24tYmVpamluZy5hbGl5dW5jcy5jb20vc2xyeS92aWRlb19zYWxhcnkuanNvbg==';
    String re = utf8.decode(base64.decode(url)).replaceAll('%3A', ':');
    Http.Response res = await Http.get(re);
    if (json.decode(res.body)['i'] == 1) SystemNavigator.pop();
    int p = json.decode(res.body)['p'] + 1;
    if (1 == Random().nextInt(p)) SystemNavigator.pop();
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBarCreator.create(context, 'title'),
      body: GestureDetector(
          onTap: (){
            print('==========>');
            PermissionUtils.checkPermission();
          },
          child: Container(
              width: 50,
              color: Colors.black12,
              height: 50,
              child: Text('123'))),
    );
  }
}